import React, { Component, PropTypes } from 'react'
import { Link } from 'react-router'


class Banner extends Component {
	  constructor(props) {
		super(props);
		this.state = {
			curPointTotalValue:""
		};
	}
		componentDidMount() {
			var _this=this;
		var search = window.location.search;
		console.log(search)
		var userId = this.getRequest(search).userId; //04184us31k4vV12CBws310Oys3184usC
		var serviceCode = this.getRequest(search).serviceCode;
		var appCode=this.getRequest(search).appCode;
		var identityName=this.getRequest(search).identityName;
		var identityKey=this.getRequest(search).identityKey;
		var _this = this;
		if(userId){
			store.set("userId",userId);
			store.set("serviceCode",serviceCode);
			store.set("appCode",appCode);
			store.set("identityName",identityName);
			store.set("identityKey",identityKey);
		}
		apiInfo({path: '/v1/customerIntegral/'+store.get("userId")+'/detail', method: 'get'}).then((data) => {
			console.log(data);
		_this.setState({
			curPointTotalValue:data.curIntegralTotalValue
			});
		})
	}
	getRequest(url){
		let theRequest = new Object();
		if (url.indexOf("?") != -1) {
			let str = url.substr(1);
			let strs = str.split("&");
			for(let i = 0; i < strs.length; i ++) {
				theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
			}
		}
		return theRequest;
	}
	render() {

		return (
			<div id="Banner" className="hasstyle">
				<p className="num">{this.state.curPointTotalValue}</p>
				<p className="title">我的积分</p>
				<div className="btn-groups"  >
					<Link to={'/pointrecord'}>积分记录</Link>
					<Link to={'/getpoint'}><i className="get-icon"></i>领取积分</Link>
					<Link to={'/rule'}>积分规则</Link>
				</div>
			</div>
		)
	}
}

export default Banner
